package project;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.*;

public class AddressPanel extends JPanel
{
	private JLabel streetL = null, suburbL = null, cityL = null,
				posCodeL = null;
	JTextField streetT = null, suburbT = null, cityT = null,
				posCodeT = null;
	private String type = null;
	
	public AddressPanel(String type)
	{
		this.type = null;
		streetL = new JLabel("Street: ", JLabel.TRAILING);
		suburbL = new JLabel("Suburb: ", JLabel.TRAILING);
		cityL = new JLabel("City: ", JLabel.TRAILING);
		posCodeL = new JLabel("Postal Code: ", JLabel.TRAILING);
		streetT = new JTextField(30);
		streetT.setMaximumSize(new Dimension(30,10));
		suburbT = new JTextField(30);
		suburbT.setMaximumSize(new Dimension(30,10));
		cityT = new JTextField(30);
		cityT.setMaximumSize(new Dimension(30,10));
		posCodeT = new JTextField(5);
		posCodeT.setMaximumSize(new Dimension(30,10));
		if(type.equals("Residential"))
		{
			//this.setBorder(BorderFactory.createTitledBorder(
			//		"Residential Address"));
			Font font = streetL.getFont();
			String fontName = font.getFontName();
			font = new Font(fontName, Font.ITALIC, 13);
			this.setBorder(BorderFactory.createTitledBorder(
								null,
		                     	"Address",
                                TitledBorder.DEFAULT_JUSTIFICATION,
                                TitledBorder.DEFAULT_POSITION,
                                font));
		}
		if(type.equals("Postal"))
		{
			//this.setBorder(BorderFactory.createTitledBorder(
			//		"Postal Address"));
			Font font = streetL.getFont();
			String fontName = font.getFontName();
			font = new Font(fontName, Font.ITALIC, 13);
			this.setBorder(BorderFactory.createTitledBorder(
								null,
		                     	"Postal Address",
                                TitledBorder.DEFAULT_JUSTIFICATION,
                                TitledBorder.DEFAULT_POSITION,
                                font));
		}
	
		
		this.setLayout(new SpringLayout());
		this.add(streetL);
		streetL.setLabelFor(streetT);
		this.add(streetT);
		this.add(suburbL);
		suburbL.setLabelFor(suburbT);
		this.add(suburbT);
		this.add(cityL);
		cityL.setLabelFor(cityT);
		this.add(cityT);
		this.add(posCodeL);
		posCodeL.setLabelFor(posCodeT);
		this.add(posCodeT);
		
		SpringUtilities.makeCompactGrid(this,
                                        4, 2, //rows, cols
                                        6, 6,        //initX, initY
                                        6, 6);       //xPad, yPad

		this.setOpaque(true);
		
	}
}